<?php 
require_once 'SqlHelper.php';
//该类是一个业务逻辑处理类,主要完成对admin表操作
class AdminService{
    public function checkAdmin($id,$password){
        $sql="select name,password from admin where id=$id";
        
        //创建一个sqlhelper对象
        $sqlhelper=new SqlHelper();
        
        $res=$sqlhelper->execute_dql($sql);
        
        if($row=mysqli_fetch_assoc($res)){
            if(md5($password)==$row['password']){
                return $row['name'];
            }else{
                return "";
            }
        }
        return "";
    }
    public function getPassword($id){
        $sql="select password from admin where id=$id";
        //创建一个sqlhelper对象
        $sqlhelper=new SqlHelper();
        $res=$sqlhelper->execute_dql2($sql);
        $sqlhelper->close_sql();
        return $res;
    }
}
?>